#pragma once

#include "RenderTarget.h"

class ResolveRenderTarget : public RenderTarget
{
	struct BuilderDetails {

		bool isMultiple;

		VkFormat format;
		uint32 width;
		uint32 height;
		VkImageUsageFlags usage;
		VkSharingMode sharingMode;
		std::vector<VkQueueFlagBits> queueFamilys;

		VkAttachmentLoadOp loadOp;
		VkAttachmentStoreOp storeOp;
		VkAttachmentLoadOp stencilLoadOp;
		VkAttachmentStoreOp stencilStoreOp;
		VkImageLayout initialLayout;
		VkImageLayout finalLayout;

		VkClearColorValue clearColorValue;

		BuilderDetails();
	};

public:

	class Builder : public BuilderBase<BuilderDetails> {
		friend struct BuilderDetails;
	public:
		Builder() noexcept;
		Builder(Builder const& rhs) noexcept;
		Builder(Builder&& rhs) noexcept;
		~Builder() noexcept;
		Builder& operator=(Builder const& rhs) noexcept;
		Builder& operator=(Builder&& rhs) noexcept;

		Builder& SetMultiple(bool isMultiple) noexcept;

		Builder& SetFormat(VkFormat format) noexcept;
		Builder& SetWidth(uint32 width) noexcept;
		Builder& SetHeight(uint32 height) noexcept;
		Builder& SetUsage(VkImageUsageFlags usage) noexcept;
		Builder& SetSharingMode(VkSharingMode sharingMode) noexcept;
		Builder& AddQueueFamily(VkQueueFlagBits queueFlag) noexcept;

		Builder& SetLoadOp(VkAttachmentLoadOp loadOp) noexcept;
		Builder& SetStoreOp(VkAttachmentStoreOp storeOp) noexcept;
		Builder& SetStencilLoadOp(VkAttachmentLoadOp stencilLoadOp) noexcept;
		Builder& SetStencilStoreOp(VkAttachmentStoreOp stencilStoreOp) noexcept;
		Builder& SetInitialLayout(VkImageLayout initialLayout) noexcept;
		Builder& SetFinalLayout(VkImageLayout finalLayout) noexcept;

		Builder& SetClearColorValue(VkClearColorValue clearColorValue) noexcept;

		RefCountPtr<ResolveRenderTarget> Build();
		RefCountPtr<ResolveRenderTarget> Build(RenderProcess* process, const std::string& name);

	private:
		friend class ResolveRenderTarget;
	};

	ResolveRenderTarget(BuilderDetails& builderDetails);

	virtual void ReleaseResource() override;
};